package com.villaday.idf.adapter3;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.fragment.OrdinaryVipFragment;
import com.villaday.idf.model3.MemberConfigurations;
import com.villaday.idf.util.JumpUtils;
import com.villaday.idf.util.ShareUtils;

public class YaoXinHeadAdapter extends AbsRecyclerViewAdapter<MemberConfigurations.BodyBean.TasksBean> {
    private OrdinaryVipFragment.Jumps jumps;
    private OrdinaryVipFragment.OnViplPageListener VPListener;
    private OrdinaryVipFragment ordinaryVipFragment;

    public YaoXinHeadAdapter(Context context, OrdinaryVipFragment.Jumps jumps, OrdinaryVipFragment.OnViplPageListener VPListener,OrdinaryVipFragment ordinaryVipFragment) {
        super(context, R.layout.yxzq_head);
        this.jumps = jumps;
        this.VPListener = VPListener;
        this.ordinaryVipFragment = ordinaryVipFragment;
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, final MemberConfigurations.BodyBean.TasksBean d, int position) {
        TextView view = (TextView) holder.getView(R.id.tv_bt);
        if (d.getButton().isClick()) {
            view.setEnabled(true);
            view.setBackground(context.getResources().getDrawable(R.drawable.vip_item_shape));
            view.setTextColor(Color.parseColor("#ffffffff"));
        } else {
            view.setEnabled(false);
            view.setBackground(context.getResources().getDrawable(R.drawable.vip_item_shape_gray));
            view.setTextColor(Color.parseColor("#ffffffff"));
        }

        holder.bindSimpleDraweeView(R.id.sdv_vip, d.getIcon())
                .bindTextView(R.id.tv_title, d.getName())
                .bindTextView(R.id.tv_des, d.getDesc())
                .bindTextView(R.id.tv_bt, d.getButton().getName())
                .setClickListener(R.id.tv_bt, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {//跳转
                        JumpUtils.jump(context,d.getJump().getJumpType(),d.getJump().getUrl(),jumps,VPListener,d.getJump().getMiniAppId(),d.getJump().getMiniProgramType());
                        ordinaryVipFragment.isClickYXZQneedReflash=true;
                    }
                });




    }
}
